/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUI.java
 *
 * Created on May 17, 2011, 5:37:32 PM
 */

package basededatos;

import java.awt.GridLayout;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Sarazua
 */
public class GUI extends javax.swing.JFrame {

    /** Creates new form GUI */
    public GUI() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jTabbedPaneTODOtAB = new javax.swing.JTabbedPane();
        jPanelCONSULTAS = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jPanelREPORTES = new javax.swing.JPanel();
        BotonReporte1 = new javax.swing.JButton();
        BotonReporte2 = new javax.swing.JButton();
        BotonReporte3 = new javax.swing.JButton();
        BotonReporte4 = new javax.swing.JButton();
        BotonReporte5 = new javax.swing.JButton();
        BotonReporte6 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jPanelADMIN = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTree1 = new javax.swing.JTree();
        BotonGestionDeClientes = new javax.swing.JButton();
        BotonGestionDeCargas = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("OCR A Extended", 1, 24));
        jLabel1.setText("SERLIPSA");

        jTabbedPaneTODOtAB.setBackground(new java.awt.Color(255, 255, 255));

        jPanelCONSULTAS.setBackground(new java.awt.Color(255, 255, 255));

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 742, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 153, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanelCONSULTASLayout = new javax.swing.GroupLayout(jPanelCONSULTAS);
        jPanelCONSULTAS.setLayout(jPanelCONSULTASLayout);
        jPanelCONSULTASLayout.setHorizontalGroup(
            jPanelCONSULTASLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCONSULTASLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanelCONSULTASLayout.setVerticalGroup(
            jPanelCONSULTASLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCONSULTASLayout.createSequentialGroup()
                .addGap(212, 212, 212)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jTabbedPaneTODOtAB.addTab("Consultas", jPanelCONSULTAS);

        BotonReporte1.setIcon(new javax.swing.ImageIcon("C:\\Users\\Sarazua\\Desktop\\png\\32x32\\chart_add.png")); // NOI18N
        BotonReporte1.addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentAdded(java.awt.event.ContainerEvent evt) {
                BotonReporte1ComponentAdded(evt);
            }
            public void componentRemoved(java.awt.event.ContainerEvent evt) {
                BotonReporte1ComponentRemoved(evt);
            }
        });
        BotonReporte1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonReporte1ActionPerformed(evt);
            }
        });

        BotonReporte2.setIcon(new javax.swing.ImageIcon("C:\\Users\\Sarazua\\Desktop\\png\\24x24\\application_edit.png")); // NOI18N
        BotonReporte2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonReporte2ActionPerformed(evt);
            }
        });

        BotonReporte3.setIcon(new javax.swing.ImageIcon("C:\\Users\\Sarazua\\Desktop\\png\\Income-icon.png")); // NOI18N

        BotonReporte4.setIcon(new javax.swing.ImageIcon("C:\\Users\\Sarazua\\Desktop\\png\\money.PNG")); // NOI18N

        BotonReporte5.setIcon(new javax.swing.ImageIcon("C:\\Users\\Sarazua\\Desktop\\png\\Date-and-Time-icon.png")); // NOI18N
        BotonReporte5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonReporte5ActionPerformed(evt);
            }
        });

        BotonReporte6.setIcon(new javax.swing.ImageIcon("C:\\Users\\Sarazua\\Desktop\\png\\cabinet-icon.png")); // NOI18N
        BotonReporte6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonReporte6ActionPerformed(evt);
            }
        });

        jLabel3.setText("Reporte de la carga ingresada en un período de tiempo");

        jLabel4.setText("Reporte de estados de los almacenes");

        jLabel5.setText("Reporte de los montos pagados por el cliente para sacar su carga");

        jLabel6.setText("Reporte de la carga egresada en un período de tiempo ");

        jLabel7.setText("Reporte consolidado de los pesos mensuales ingresados y egresados en un año determinado");

        jLabel8.setText("Reporte  de la carga declarada en abandono legal en un período de tiempo");

        javax.swing.GroupLayout jPanelREPORTESLayout = new javax.swing.GroupLayout(jPanelREPORTES);
        jPanelREPORTES.setLayout(jPanelREPORTESLayout);
        jPanelREPORTESLayout.setHorizontalGroup(
            jPanelREPORTESLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(jPanelREPORTESLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                        .addComponent(BotonReporte6, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8))
                    .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                        .addComponent(BotonReporte5, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel7))
                    .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                        .addComponent(BotonReporte4, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6))
                    .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                        .addComponent(BotonReporte3, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5))
                    .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                        .addComponent(BotonReporte2, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel4))
                    .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                        .addComponent(BotonReporte1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel3)))
                .addContainerGap(248, Short.MAX_VALUE))
        );
        jPanelREPORTESLayout.setVerticalGroup(
            jPanelREPORTESLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                .addGroup(jPanelREPORTESLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(BotonReporte1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BotonReporte2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BotonReporte3, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BotonReporte4, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BotonReporte5, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BotonReporte6, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelREPORTESLayout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addComponent(jLabel3)
                        .addGap(28, 28, 28)
                        .addComponent(jLabel4)
                        .addGap(28, 28, 28)
                        .addComponent(jLabel5)
                        .addGap(31, 31, 31)
                        .addComponent(jLabel6)
                        .addGap(28, 28, 28)
                        .addComponent(jLabel7)
                        .addGap(28, 28, 28)
                        .addComponent(jLabel8)))
                .addContainerGap(111, Short.MAX_VALUE))
        );

        jTabbedPaneTODOtAB.addTab("Reportes", jPanelREPORTES);

        jPanelADMIN.setBackground(new java.awt.Color(255, 255, 255));

        jScrollPane1.setViewportView(jTree1);

        BotonGestionDeClientes.setText("Gestion de clientes");
        BotonGestionDeClientes.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                BotonGestionDeClientesMouseClicked(evt);
            }
        });
        BotonGestionDeClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonGestionDeClientesActionPerformed(evt);
            }
        });

        BotonGestionDeCargas.setText("Gestion de Cargas");

        jButton3.setText("Gestion de pagos");

        javax.swing.GroupLayout jPanelADMINLayout = new javax.swing.GroupLayout(jPanelADMIN);
        jPanelADMIN.setLayout(jPanelADMINLayout);
        jPanelADMINLayout.setHorizontalGroup(
            jPanelADMINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelADMINLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelADMINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanelADMINLayout.createSequentialGroup()
                        .addComponent(BotonGestionDeClientes)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(BotonGestionDeCargas)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton3))
                    .addComponent(jSeparator1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 207, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelADMINLayout.setVerticalGroup(
            jPanelADMINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelADMINLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelADMINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)
                    .addGroup(jPanelADMINLayout.createSequentialGroup()
                        .addGroup(jPanelADMINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(BotonGestionDeClientes)
                            .addComponent(BotonGestionDeCargas)
                            .addComponent(jButton3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jTabbedPaneTODOtAB.addTab("Admin", jPanelADMIN);

        jLabel2.setText("17 de marzo del 2011");

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(318, 318, 318)
                .addComponent(jLabel1)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(791, Short.MAX_VALUE)
                .addComponent(jLabel2))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPaneTODOtAB, javax.swing.GroupLayout.DEFAULT_SIZE, 771, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1))
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPaneTODOtAB, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
                .addGap(11, 11, 11))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BotonGestionDeClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonGestionDeClientesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_BotonGestionDeClientesActionPerformed

    private void BotonReporte5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonReporte5ActionPerformed
        //218
        JFrame frame = new JFrame("Reporte consolidado de los pesos mensuales ingresados y egresados en un año determinado");
        JButton button = new JButton("Aceptar");
        JLabel label = new JLabel("HOLAHOLA");
        frame.add(button);
        frame.add(label);
        frame.setSize(400,400);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }//GEN-LAST:event_BotonReporte5ActionPerformed

    private void BotonReporte6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonReporte6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_BotonReporte6ActionPerformed

    private void BotonReporte1ComponentAdded(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_BotonReporte1ComponentAdded
        // TODO add your handling code here:
    }//GEN-LAST:event_BotonReporte1ComponentAdded

    private void BotonReporte1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonReporte1ActionPerformed
        
        //frame = new JFrame ()
        String periodoInicio = JOptionPane.showInputDialog("Ingrese la fecha de inicio del periodo aa/mm/dd");
        String periodoFinal = JOptionPane.showInputDialog("Ingrese la fecha de final del periodo aa/mm/dd");
        Date fechaInicio=null,fechaFinal=null;
        SimpleDateFormat formato = new SimpleDateFormat("yyyy-MM-dd");
        try{
            fechaInicio = formato.parse(periodoInicio);
            fechaFinal = formato.parse(periodoFinal);
            System.out.println("Inicio"+fechaInicio);
            System.out.println("Final"+fechaFinal);
        } catch(ParseException ex){
            ex.printStackTrace();
            JOptionPane.showMessageDialog(null,"Error al ingresar la fecha");
        }
        if(fechaInicio.equals(fechaFinal)||(fechaInicio.after(fechaFinal))){
            conexionReporte1(fechaInicio,fechaFinal);
        } else{
            JOptionPane.showMessageDialog(null,"El periodo no es valido");
        }

        
        //        JFrame frame = new JFrame("Reporte de la carga ingresada en un período de tiempo");
//
//        JLabel label = new JLabel("Año");
//        JLabel label1 = new JLabel("Mes");
//        JLabel label2 = new JLabel("Día");
//        JTextField anio = new JTextField();
//        JTextField mes = new JTextField();
//        JTextField dia = new JTextField();
//        frame.add(label);
//        frame.add(anio);
//        frame.add(label1);
//        frame.add(mes);
//        frame.add(label2);
//        frame.add(dia);
//        frame.setSize(400,400);
//        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//        frame.setVisible(true);
    }//GEN-LAST:event_BotonReporte1ActionPerformed

    private void BotonReporte1ComponentRemoved(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_BotonReporte1ComponentRemoved
        // TODO add your handling code here:        
    }//GEN-LAST:event_BotonReporte1ComponentRemoved

    private void BotonGestionDeClientesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BotonGestionDeClientesMouseClicked
        // TODO add your handling code here:       
    }//GEN-LAST:event_BotonGestionDeClientesMouseClicked

    private void BotonReporte2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonReporte2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_BotonReporte2ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonGestionDeCargas;
    private javax.swing.JButton BotonGestionDeClientes;
    private javax.swing.JButton BotonReporte1;
    private javax.swing.JButton BotonReporte2;
    private javax.swing.JButton BotonReporte3;
    private javax.swing.JButton BotonReporte4;
    private javax.swing.JButton BotonReporte5;
    private javax.swing.JButton BotonReporte6;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanelADMIN;
    private javax.swing.JPanel jPanelCONSULTAS;
    private javax.swing.JPanel jPanelREPORTES;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPaneTODOtAB;
    private javax.swing.JTree jTree1;
    // End of variables declaration//GEN-END:variables

    private void conexionReporte1(Date inicio, Date fin ) {
        String driver, user, pass, direccion;
        Scanner scan = new Scanner(System.in);
        try {
            driver = "org.postgresql.Driver";
            user = "postgres";
            pass = "postgres";
            direccion = "jdbc:postgresql://localhost:5432/proy1/";

            Class.forName(driver);
            Connection conexion = DriverManager.getConnection(direccion, user, pass);
            System.out.println("Conexion realizar con exito");
                Statement inst = conexion.createStatement();
                ResultSet rs;
                // * Select getCargas (1)
                String querry = "Select *from reporte1('2011-01-01', '2011-12-01') as (IdCarga integer, IdCliente integer, NombreCliente varchar(200), FechaIngreso timestamp, FechaSalida timestamp, Refrigerada boolean, PesoCarga integer, IdAlmacen integer, Fila integer, Columna integer, IdRack integer)";
                rs = inst.executeQuery(querry);
                JPanel Resultado = new JPanel();
                String[]  Nombrecolumnas = {"ID Carga","ID Cliente","Nombre Cliente","Fecha de Ingreso", "Fecha de Salida",  "Refrigerada","Peso de la Carga" ,"Id del Almacen","Fila","Columna","Id del Rack"};
                 Object[][] datos;
                DefaultTableModel modelo = new DefaultTableModel();
                JTable tabla = new JTable(modelo);

                while (rs.next()) {

                    Object [] newRow = {rs.getString("IdCarga"),rs.getString("IdCliente"),rs.getString("FechaIngreso"),};
                }
                inst.execute("END");
                inst.close();
                conexion.close();
        } catch (Exception e) {
            System.out.println("No se pudo realizar la Conexion");
            e.printStackTrace();
        }
    }


}
